home *** CD-ROM | disk | FTP | other *** search
/ Shareware Grab Bag / Shareware Grab Bag.iso / 007 / cstdio.arc / SRC.ARC / STRNCPY.C < prev    next >
C/C++ Source or Header  |  1984-07-29  |  366b  |  21 lines

  1. /*    strncpy.c - copy exactly n characters from s2 to s1.
  2.     (C) Copyright 1984 Gregory R. Mansfield - All Rights Reserved.
  3.     G. R. Mansfield.  84/06/09.
  4.     Ver 1.0-4729.
  5. */
  6.  
  7. char *strncpy(s1, s2, n)    /* copy t to s */
  8. char *s1, *s2;
  9. int n;
  10. {
  11.     char *p;
  12.  
  13.     p = s1;
  14.     while (*p++ = *s2++)
  15.         if (--n == 0)
  16.             break;
  17.     while (n--)
  18.         *p++ = '\0';
  19.     return(s1);
  20. }
  21.